﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Showme.Controllers;

namespace Showme
{
    public partial class LoginForm : Form
    {

        ShowmeController controller;

        public LoginForm()
        {
            this.controller = ShowmeController.Instance;
            InitializeComponent();
        }

        private void btn_login_Click_1(object sender, EventArgs e)
        {            
            if (controller.login(txt_username.Text, txt_password.Text))
            {
                this.Hide();
                switch (controller.currentUser.userType)
                {
                    case Data.Objects.UserType.Manager:   // Manager View
                        ManagerMain managerMain = new ManagerMain();
                        managerMain.ShowDialog();
                        this.Close();
                        break;
                    case Data.Objects.UserType.Customer:     // Customer View
                        CustomerMain customerMain = new CustomerMain();
                        customerMain.ShowDialog();
                        this.Close();
                        break;
                    case Data.Objects.UserType.Dispatcher:     // Dispatcher View
                        DispatcherMenu dispatcherMain = new DispatcherMenu();
                        dispatcherMain.ShowDialog();
                        this.Close();
                        break;
                    case Data.Objects.UserType.Technician:     // Technician View
                        TechnicianMenu technicianMain = new TechnicianMenu();
                        technicianMain.ShowDialog();
                        this.Close();
                        break;
                    case Data.Objects.UserType.Media:     // Media Manager View
                        MediaManagerMain mediaMain = new MediaManagerMain();
                        mediaMain.ShowDialog();
                        this.Close();
                        break;
                }
            }
            else
            {
                MessageBox.Show("Username or password error. \n Please try again.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {

        }
    }
}
